<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="btn">点我一下</button>
    <ul id="list">
        <li><a href="javascript:;">链接一</a></li>
        <li><a href="javascript:;">链接二</a></li>
        <li><a href="javascript:;">链接三</a></li>
        <li><a href="javascript:;">链接四</a></li>
    </ul>

    <script>
        /* 
            将事件统一绑定给 document,然后点击超链接时由于事件的冒泡，
                会导致document上的点击事件被触发，这样只绑定一次，所有的超链接都会具有这些事件
        */

        // const links = document.querySelectorAll('ul a');
        const list = document.getElementById('list');
        const btn = document.getElementById('btn');

        const links_list = list.getElementsByTagName('a');

        list.addEventListener("click", event => {
            if(event.target.tagName === 'A')
            console.log(event.target);
        });

        btn.addEventListener("click", () => {
            list.insertAdjacentHTML("beforeend", "<li><a href='javascript:;'>链接五</a></li>")
        })
    </script>
</body>
</html>